﻿#include <chrono>
#include <iostream>
#include <string>
#include <thread>
#include "zmq.hpp"

int main() {
  // initialize the zmq context with a single IO thread
  zmq::context_t context{1};

  zmq::socket_t socket{context, zmq::socket_type::pub};
  socket.connect("tcp://127.0.0.1:9527");

  const std::string topicA{"myTopicA"};
  const std::string topicB{"myTopicB"};
  const std::string topicC{"myTopicC"};

  while (true) {
    static int num{0};
    socket.send(zmq::buffer(topicA), zmq::send_flags::sndmore);
    socket.send(zmq::buffer(topicA + ":" + std::to_string(num)));

    socket.send(zmq::buffer(topicB), zmq::send_flags::sndmore);
    socket.send(zmq::buffer(topicB + ":" + std::to_string(num)));

    socket.send(zmq::buffer(topicC), zmq::send_flags::sndmore);
    socket.send(zmq::buffer(topicC + ":" + std::to_string(num)));

    ++num;
    std::this_thread::sleep_for(std::chrono::milliseconds{1000});
  }
}
